# # a = open('密码.txt', 'r')
# # b = a.readlines()
# #
# # new_list = []
# # for line in b:
# #     for item in line.strip().split():
# #         new_list.append(item)
# # #print(new_list)
# # s=new_list
# # c=3437
# # while True:
# #     if new_list[0] == c:
# #         print('ok')
# #     else:
# #         new_list[0] += 1
#
#
# txt_tables = []
# f = open("密码.txt", "r", encoding='utf-8')
# line = f.readline()  # 读取第一行
# while line:
#     txt_data = eval(line)  # 可将字符串变为元组
#     txt_tables.append(txt_data)  # 列表增加
#     line = f.readline()  # 读取下一行
# # print(txt_tables)
#
# s = txt_tables
# # print(s[0])
# c = 3437
# while True:
#     if s[0] == c:
#         s[0] += 1
#         print('ok')
#     else:
#         s[0] += 1


from itertools import product

# product作用：将提供的容器中的所有元素排列组合形式按照指定的长度完全列出来
# 1.将数字、字母放入容器中
# 2.指定长度范围
# 3.开始生成“密码”

list1 = [chr(i) for i in range(48, 58)]  # 0-9的ASCLL码值
# list2 = [chr(i) for i in range(65, 91)]  # A-Z的ASCLL码值
# list3 = [chr(i) for i in range(97, 123)]  # a-z的ASCLL码值
newlist = list1  # + list2 + list3
print(newlist)

# 指定长度范围
for length in range(4, 12):
    # product(字符串容器,repeat=长度)
    for i in product(newlist, repeat=8):  # 开始生成密码
        result = ''.join(i)+'\n'
        fileName = '密码.txt'
        with open(fileName, 'a', encoding='utf-8') as file:
            file.write(result)
        print(result)

def remove_duplicates():
    f_read=open(r'./密码.txt','r',encoding='utf-8')     #将需要去除重复值的txt文本重命名text.txt
    f_write=open(r'./1密码.txt','w',encoding='utf-8')  #去除重复值之后，生成新的txt文本 --“去除重复值后的文本.txt”
    data=set()
    for a in [a.strip('\n') for a in list(f_read)]:
        if a not in data:
            f_write.write(a+'\n')
            data.add(a)
    f_read.close()
    f_write.close()
remove_duplicates()
print('完成')




# s = result
# c = 3437
# while True:
#     if s[0] == c:
#         s[0] += 1
#         print('ok')
#     else:
#         s[0] += 1







